package com.itttq.im.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@ConfigurationProperties(prefix = "fyim.ws")
@Component
public class WsProperties {
    /**
     * 端口
     */
    public static int httpPort = 8080;
    /**
     * 端口
     */
    public static int wsPort = 10000;
    /**
     * 空闲时长（s）
     */
    public static int idleTime = 9;
    /**
     * 超时断开连接时长（s）
     */
    public static int timeout = 30;
    /**
     * 本地IP地址
     */
    public static String localIp = "127.0.0.1";

    @Value("${server.port}")
    public void setHttpPort(int httpPort) {
        WsProperties.httpPort = httpPort;
    }

    public void setWsPort(int wsPort) {
        WsProperties.wsPort = wsPort;
    }

    public void setIdleTime(int idleTime) {
        WsProperties.idleTime = idleTime;
    }

    public void setTimeout(int timeout) {
        WsProperties.timeout = timeout * 1000;
    }

    public void setLocalIp(String localIp) {
        WsProperties.localIp = localIp;
    }
}
